<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>height-transition</title>
    <style>
        .trigger {
            cursor: pointer;
            border-bottom: 1px solid #2396ef;
        }
        .el {
            transition: max-height .4s;
            overflow: hidden;
            max-height: 0;
        }
        .trigger:hover > .el {
            max-height: var(--max-height--);
        }
    </style>
</head>
<body>
    <div class="trigger">
        Hover me to see a height transition.
        <div class="el">Additional content</div>
    </div>
    <script>
        const el = document.querySelector('.el'),
              height = el.scrollHeight;
        el.style.setProperty('--max-height--',height + 'px');
    </script>
</body>
</html>